<style>
    .xxpayPopupDiv .layui-form-label {
        width:15% !important;
        margin-left:1%;
    }
    .xxpayPopupDiv .layui-input-inline {
        width: 33% !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <form class="layui-form layui-form-pane">
            <div class="layui-tab layui-tab-brief">
                <div class="layui-tab-content">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red">* </span>代理商名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="agentName" name="agentName" lay-verify="required" placeholder="输入代理商名称" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label"><span style="color: red">* </span>用户登录名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="userName" name="userName" lay-verify="required" placeholder="输入用户登录名" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red">* </span>手机号</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="mobile" name="mobile" lay-verify="phone" placeholder="输入手机号" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label"><span style="color: red">* </span>邮箱</label>
                        <div class="layui-input-inline">
                            <input type="text" id="email" name="email" lay-verify="email" placeholder="输入邮箱" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red">* </span>真实姓名</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="realName" name="realName" lay-verify="required" placeholder="输入真实姓名" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">身份证号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="idCard" name="idCard" placeholder="输入身份证号" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">座机号码</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="tel" name="tel" placeholder="输入座机号" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">QQ号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="qq" name="qq" placeholder="输入QQ号" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">通讯地址</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="address" name="address" placeholder="输入通讯地址" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="status" value="1" title="启用" checked="checked">
                            <input type="radio" name="status" value="0" title="停止">
                        </div>
                    </div>
                    <input type="hidden" id="parentAgentId" name="parentAgentId" placeholder="一级代理ID" autocomplete="off" class="layui-input">
                </div>

                <button class="layui-hide xxpayYesBtn" lay-submit lay-filter="agentAdd">保存</button>
            </div>
        </form>
    </div>
</div>

<script>
    layui.use(['admin', 'form'],function(){
        var form = layui.form
        ,$ = layui.$
        ,admin = layui.admin
        ,element = layui.element
        ,layer = layui.layer
        ,view = layui.view ;

        element.render('breadcrumb', 'breadcrumb');
        
        admin.req({
           type: 'get',
           url:  layui.setter.baseUrl + '/agent/get' //模拟基本信息接口,
           ,error: function(err){
               console.log(err)
           },
           success: function(res){
               if(res.code == 0){
                   $('#parentAgentId').val(res.data.agentId);
               }
           }
        })
        
        form.on('submit(agentAdd)', function(data) {
            //这里可以写ajax方法提交表单
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/agent/add',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "提示"}, function(index){

                            layer.closeAll(); //关闭所有弹层
                            layui.table.reload('tableReload'); //调用业务弹层外表格重新加载
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        form.render();
    })
</script>